<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="https://cdn.staticfile.net/jquery/1.10.2/jquery.min.js"></script>
<script>
    $(function (){
        $("#username").blur(function (){
            $.ajax({
                type:"POST",
                url:"/checkName",
                data:{"username":$("#username").val()
                },
                success:function (result){
                    if(result == "true"){
                        $("#msg").html("用户名已经存在").css("color","red");
                    }else{
                        $("#msg").html("可以使用").css("color","green");
                    }
                }
            });
        });
    })
</script>
<body>
请输入注册账号：<input type="text" name="username" id="username" autocomplete="off">
<span id="msg"></span>
</body>
</html>